package com.ljkj.lawyer.lawyer.controller;


import com.ljkj.lawyer.lawyer.common.MessageResult;
import com.ljkj.lawyer.lawyer.param.AddParam;
import com.ljkj.lawyer.lawyer.service.LawyerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gaokecheng
 * @since 2021-11-02
 */
@RestController
@RequestMapping("/lawyer")
public class LawyerController {

    @Autowired
    private LawyerService lawyerService;

    /**
     * 信息填写
     */
    @PostMapping("/addOrUpdateLawyerInfo")
    public MessageResult addLawyerInfo(@RequestBody @Valid AddParam addParam) {
        return lawyerService.addLawyerInfo(addParam);
    }

    /**
     * 获取最新用户详细信息
     */
    @GetMapping("/getLastLawyerInfoByMemberId")
    public MessageResult getLawyerInfoByMemberId(@RequestParam("memberId") Integer memberId) {
        return lawyerService.getLastLawyerInfoByMemberId(memberId);
    }

    /**
     * 根据hashCode获取数据
     */
    @GetMapping("/getDataByHashCode")
    public MessageResult getDataByHashCode(@RequestParam("hashCode") String hashCode) {
        return lawyerService.getDataByHashCode(hashCode);
    }

    /**
     * 根据hashCode获取文件数据流
     */
    @GetMapping("/getHashCodeListByMemberId")
    public MessageResult getHashCodeListByMemberId(@RequestParam("memberId") Integer memberId,@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,@RequestParam(value = "pageSize",defaultValue = "5")Integer pageSize) {
        return lawyerService.getHashCodeListByMemberId(memberId,pageNum,pageSize);
    }

    /**
     * 根据hashCode获取文件数据流
     */
    @GetMapping("/getLawyerHistoryByMemberId")
    public MessageResult getLawyerHistoryByMemberId(@RequestParam("memberId") Integer memberId,@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,@RequestParam(value = "pageSize",defaultValue = "5")Integer pageSize) {
        return lawyerService.getLawyerHistoryByMemberId(memberId,pageNum,pageSize);
    }


}

